(function () {
	var ns = ij.pkg('core').namespaceString;
	ij.core.GameObject = ij.core.AnimatedObject.extend({
		init: function (config) {
			return this._super(ij.apply({
				classname: ns + '.GameObject',
				objects: [],
				forces: [],
				fX: 0,
				fY: 0,
				mass: 10
			}, config));
		},
		add: function (gameObject) {
			if (gameObject instanceof ij.core.GameObject) {
				if (this.objects.indexOf(gameObject) == -1) {
					this.objects.push(gameObject);
				}
			}
		},
		update: function () {
			this._super();
			this.moveBy(this.fX, this.fY);
			
			return this;
		},
		intersects: function (obj) {
			var res = {};
			res.left = this.x - (obj.x + obj.width);
			res.right = obj.x - (this.x + this.width);
			res.top = this.y - (obj.y + obj.height);
			res.bottom = obj.y - (this.y + this.height);
			res.result = !(res.left > 0 || res.right > 0 || res.top > 0 || res.bottom > 0);
			return res;
		}
	});
})();
